package cn.bluemobi.dylan.step.presenter;

import android.os.Handler;
import android.text.TextUtils;



import javax.inject.Inject;

import cn.bluemobi.dylan.step.base.RxPresenter;
import cn.bluemobi.dylan.step.moder.bean.User;
import cn.bluemobi.dylan.step.moder.prefs.Prefs;
import cn.bluemobi.dylan.step.moder.prefs.SharedPreferencesHelper;
import cn.bluemobi.dylan.step.presenter.contract.WelcomeContract;

/**
 * Created by $Liudan on 2018/8/7 0007.
 */
public class WelcomePresenter extends RxPresenter<WelcomeContract.View> implements WelcomeContract.Presenter {
    @Inject
    SharedPreferencesHelper prefHelper;
    @Inject
    public WelcomePresenter() {

    }

    @Override
    public void getWelcomeData() {
        new Handler() {
            public void handleMessage(android.os.Message msg) {
                User user = getUser();
                if (user!=null && !TextUtils.isEmpty(user.memberPhone)) {
                    mView.jumpToMain();
                } else {
                    mView.jumpToLogin();
                }
            }
        }.sendEmptyMessageDelayed(0, 2000);
    }

    private User getUser() {
        return prefHelper.getPrefObject(Prefs.key_user, User.class);
    }
}
